home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Games Collection 1
/
software vault.zip
/
software vault
/
CDR10
/
YICN23.ZIP
/
UNITS
/
SCRIPT.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-12
|
1KB
|
41 lines
#include "script.h"
// script.cpp is the file used to form actor scripts.
// following are the defined commands.
scriptNode::scriptNode(byte icommand, int ix, int iy, int isquareX, int isquareY)
{
command = icommand;
mapX = ix;
mapY = iy;
squareX = isquareX;
squareY = isquareY;
}
void script::advanceLine()
{
if (thisLine != NULL)
thisLine = thisLine->nextLine;
}
void script::addLine(byte command, int mapX, int mapY, int squareX, int squareY)
{
if (firstLine == NULL)
firstLine = thisLine = lastLine = new scriptNode(command, mapX, mapY, squareX, squareY);
else
{
lastLine->nextLine = new scriptNode(command, mapX, mapY, squareX, squareY);
lastLine = lastLine->nextLine;
}
lastLine->nextLine = NULL;
}
void script::addCommand(scriptNode::scriptCommand command, int mapX, int mapY, int squareX, int squareY)
{
switch(command)
{
case scriptNode::doNothing :
case scriptNode::turn :
case scriptNode::fineMoveRel : addLine(command, mapX, mapY, squareX, squareY); break;
case scriptNode::fineSlide : for (int counter = 0; counter < mapX; ++counter)
addLine(scriptNode::fineMoveRel, 0,0, squareX/mapX, squareY/mapX); break;
}
}